<%@language=vbscript%>
<% 
	Session("FormName")="F47"
	Session("VanBan")=""
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="vi">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel=stylesheet href="..\CSS\FormStyle.css" type="text/css">
<script language="javascript" src="..\JS\toolBarButton.js"></script>
</head>
<!--#include file="..\jvGrid.inc"-->
<!--#include file="..\RootContent.inc"-->
<%
	bdate=Request("bdate")
	trangthai=Request("trangthai")
	if bdate="" then
		bdate=date()
	end if
	Set bDir=server.CreateObject("ActiveFile.Directory")
     bPathFolder=RootContent & "giaoban\"& Nam(Formatdate(bdate)) &"\quy"
     bDir.Path=bPathFolder
     if not bDir.Exists() then
	    	call bDir.Create(bPathFolder)
	end if
	Set bDir=nothing
	set TextFile=server.CreateObject("Vinalines.ClsFile")
	if trangthai="ghi" then
		btext=Request("Body")
		Path=bPathFolder & "\"&  Session("bMaDonVi") & "_" & Quy(Formatdate(bdate)) & "_" & Nam(Formatdate(bdate)) & ".VT"
		TextFile.SaveFile btext,Path
	else
		Path=bPathFolder & "\"&  Session("bMaDonVi") & "_" & Quy(Formatdate(bdate)) & "_" & Nam(Formatdate(bdate)) & ".VT"
		btext=TextFile.ReadTextFile(Path)
	end if
	Set TextFile=nothing
%>
<!--#include file="..\jvfunction.inc"-->
<script language=VBScript runat=server>
Function FormatDate(vDate)
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	End If
End Function
Function ModiString(mess_s)
		message = Replace("" & mess_s,"'", "''")
		ModiString=message
End function
Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
End Function
Function Quy(strdate)
	bthang=cint(mid(strdate,4,2))
	select case bthang
		case 1
			Quy=1
		case 2
			Quy=1
		case 3
			Quy=1
		case 4
			Quy=2
		case 5
			Quy=2
		case 6
			Quy=2
		case 7
			Quy=3
		case 8
			Quy=3
		case 9
			Quy=3
		case 10
			Quy=4
		case 11
			Quy=4
		case 12
			Quy=4
	end select
End Function
Function Nam(strdate)
	Nam=cint(mid(strdate,7,4))
End Function
</script>
<SCRIPT LANGUAGE=javascript>
function window_onload() {
		document.all.dynamsg.html=Noidung.Body.value;
	}
function cbodate_onchange(){
	bquy=Noidung.cboquy.value;
	if (bquy=="1"){
		bdate="01/01/"+Noidung.cbonam.value;
	}
	if (bquy=="2"){
		bdate="04/01/"+Noidung.cbonam.value;
	}
	if (bquy=="3"){
		bdate="07/01/"+Noidung.cbonam.value;
	}
	if (bquy=="4"){
		bdate="10/01/"+Noidung.cbonam.value;
	}
	window.Noidung.target="right"
	window.Noidung.action="frmctgbquy.asp?bdate="+bdate;
	window.Noidung.submit();
}
function CmdGHINHAN_onclick(){
	Noidung.Body.value=document.all.dynamsg.html;
	window.Noidung.target="right";
	window.Noidung.action="frmctgbquy.asp?bdate="+"<%=bdate%>"+"&trangthai=ghi";
	window.Noidung.submit();
}
</Script>
<body bgcolor=#F8F9D9 leftmargin=2 topmargin=0 style="font-family:times new roman" LANGUAGE=javascript onload="return window_onload()">
<form name="Noidung" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#7491DC" height=27>
	<tr> 
		<td align="left" valign="bottom" background='..\images\Tabs\tab_top_background_runner.gif'>
			<table onclick="window.location.replace('frmctgbtuan.asp')" style="cursor: hand;" border="0" cellspacing="0" cellpadding="0" align="left">
				<tr> 
					<td><img src="..\images\Tabs\tab_off_left.gif" height="24" width="16"></td>
					<td background="..\images\Tabs\tab_off_middle.gif">Tuần</td>
					<td><img src="..\images\Tabs\tab_off_right.gif" height="24" width="16"></td>
				</tr>
			</table>
			<table onclick="window.location.replace('frmctgbthang.asp')" style="cursor: hand;" border="0" cellspacing="0" cellpadding="0" align="left">
				<tr> 
					<td><img src="..\images\Tabs\tab_off_left.gif" height="24" width="16"></td>
					<td background="..\images\Tabs\tab_off_middle.gif">Tháng</td>
					<td><img src="..\images\Tabs\tab_off_right.gif" height="24" width="16"></td>
				</tr>
			</table>
			<table border="0" cellspacing="0" cellpadding="0" align="left">
				<tr> 
					<td><img src="..\images\Tabs\tab_on_left.gif" height="24"></td>
					<td background="..\images\Tabs\tab_on_middle.gif">Quý</td>
					<td><img src="..\images\Tabs\tab_on_right.gif" height="24"></td>
				</tr>
			</table>
			<table onclick="window.location.replace('frmctgbnam.asp')" style="cursor: hand;" border="0" cellspacing="0" cellpadding="0" align="left">
				<tr> 
					<td><img src="..\images\Tabs\tab_off_left.gif" height="24" width="16"></td>
					<td background="..\images\Tabs\tab_off_middle.gif">Năm</td>
					<td><img src="..\images\Tabs\tab_off_right.gif" height="24" width="16"></td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<table cellspacing=0 cellpadding=0 border=0 style="table-layout: fixed; height: 1px">
	<tr><td style="width: 100%; height: 1px; background-color:#D6D3CE">&nbsp;</td></tr>
</table>
<table cellspacing=0 cellpadding=0 border=0 style="table-layout: fixed; height: 1px">
	<tr><td style="width: 100%; height: 1px; background-color: 808080">&nbsp;</td></tr>
</table>
<table class=tbledit id=tbleditid border=0 cellspacing=0 cellpadding=0>
	<tr><td> 
		<table cellspacing="0">
			<tr> 
				<td><img src="..\images\icons\button_seperator.gif" align="absmiddle" width="12" height="20"></td>
				<td class="toolBarButton" title="Ghi nhận nội dung cập nhật giao ban" id=btnghinhan onaction="CmdGHINHAN_onclick()"><img src="..\images\icons\button_save.gif" align="absmiddle" width="16" height="20">&nbsp;&nbsp;Ghi nhận</td>
				<td><img src="..\images\icons\button_seperator.gif" align="absmiddle" width="12" height="20"></td>
			</tr>
		</table>
	</tr></td>
</table>
<script>
var btn;
	btn = document.getElementById("btnghinhan");createButton(btn); btn.setEnabled(true);
</script>
<table class=tblHeader id=ListHeader border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=12%>
<select size=1 name="cboquy" style="font-family: Arial;font-size:12px;text-align:center; position: relative; width:100%" LANGUAGE=javascript onchange="return cbodate_onchange()">
<%for i=1 to 4%>
<%if Quy(Formatdate(bdate))=i then%>
<option value="<%=i%>" selected>Quý <%=i%></option>
<%else%>
<option value="<%=i%>">Quý <%=i%></option>
<%end if%>
<%next%>
</select>
</td>
<td width=11%>
<select size=1 name="cbonam" style="font-family: Arial;font-size:12px;text-align:center; position: relative; width:100%" LANGUAGE=javascript onchange="return cbodate_onchange()">
<%for i=2000 to Nam(Formatdate(date()))%>
<%if Nam(Formatdate(bdate))=i then%>
<option value="<%=i%>" selected><%=i%></option>
<%else%>
<option value="<%=i%>"><%=i%></option>
<%end if%>
<%next%>
</select>
</td>
<td width=77% style="font-family:tahoma;font-size:11px"><b>&nbsp;&nbsp;Cập nhật giao ban quý&nbsp;<%=Quy(FormatDate(bdate))%>&nbsp;năm&nbsp;<%=Nam(FormatDate(bdate))%></b></td>
</tr>
</table>
<textarea name="Body" style='visibility:hidden;position:absolute;top:79px;left:0px' rows="5" cols="20%"><%=btext%></textarea>
<object id="dynamsg" width="100%" style="position:absolute;top:79px;left:0px" height="78%" data="Editor/deditor.asp" viewastext type="text/x-scriptlet"></object>
</form>
</body>